#include <pthread.h>
#include "protocol.h"

#ifndef STORAGE_H
#define STORAGE_H

#define BUFFER_SIZE 64

struct node {
    size_t length;
    struct timeval timestamp;
    tcpd_container data;
};

struct buffer {
    int head;
    int tail;
    struct node contents[BUFFER_SIZE];
    pthread_mutex_t mutex;
};

void storage_init(struct buffer*);
void put(struct buffer*, tcpd_container*, size_t);
struct timeval get(struct buffer*, uint32_t, tcpd_container*, size_t*);
uint32_t lowest_seq(struct buffer*);

#endif
